<?php

/**
 * This is the model class for table "partner_setting".
 *
 * The followings are the available columns in table 'partner_setting':
 * @property integer $partner_setting_id
 * @property integer $min
 * @property integer $max
 * @property integer $push_money
 * @property integer $partner_type
 * @property integer $is_delete
 * @property string $create_time
 * @property string $update_time
 */
class PartnerSetting extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'partner_setting';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('min, max, push_money, partner_type, is_delete', 'numerical', 'integerOnly'=>true),
			array('create_time, update_time', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('partner_setting_id, min, max, push_money, partner_type, is_delete, create_time, update_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'partner_setting_id' => yii::t('base','Partner Setting ID'),
			'min' => yii::t('base','User Min'),
			'max' => yii::t('base','User Max'),
			'push_money' => yii::t('base','Push Money'),
			'partner_type' => yii::t('base','Partner Type'),
			'is_delete' => yii::t('base','Is Use'),
			'create_time' => yii::t('base','Create Time'),
			'update_time' => yii::t('base','Update Time'),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('partner_setting_id',$this->partner_setting_id);
		$criteria->compare('min',$this->min);
		$criteria->compare('max',$this->max);
		$criteria->compare('push_money',$this->push_money);
		$criteria->compare('partner_type',$this->partner_type);
		$criteria->compare('is_delete',$this->is_delete);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return PartnerSetting the static model class
	 */
	
	public function is_delete($temp)
	{
		if($temp==1)
		    return yii::t('base','Available');
		elseif ($temp==0)
		    return yii::t('base','Overdue');
	    
	}
	
	public function PartnerType($type)
	{
		if($type==1)
		    echo '一级合作商';
		elseif ($type==2)
		    echo '二级合作商';
		elseif ($type==3)
		    echo '三级合作商';
		
	}
	
	
	
	
	
	
	
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
